The present invention relates to a method and system for graphically generating user-defined rules to be used for searching and checking a defined relationship between a set of given information. More specifically, the present invention is directed to a method and system for graphically generating user-defined rules to be used for checking the quality of languages.
The problem of writing error-free computer programs has plagued programmers since the very beginning. Sophisticated schemes for automatically discovering program errors and bugs of all kinds, including lexical, syntactic, semantic and logical, have been developed. However, these schemes have generally been directed to enforcing adherence to concrete programming standards inherent in the definition of the programming language itself and not to more extrinsic quality-related concerns, such as language evolution, portability, testing costs and language-specific feature exploitation. Many of these quality-related concerns can be expressed as rules amenable to automated implementation.
The first of these quality-related concerns is caused by the inevitable evolution of programming languages through the extension of features or the introduction of an entirely new language superset. For example, the C programming language has been extended to become the object-oriented C++ programming language. The problem with language evolution is that programmers familiar with the original language often cling to the same old programming practices more out of habit than good sense. Moreover, features formerly preferred have sometimes been refined or replaced by new features in the successor language, yet are largely ignored in favor of the old.
Another concern is portability. Experienced programmers are generally aware of the horizontal portability concerns for different target computing platforms. However, vertical portability concerns relating to the migration of language features to a standardized version of the language, such as an ANSI/ISO standard, are easily overlooked, especially when a compiler fails to implement or acknowledge the proposed standardized features.
A third concern is avoiding unnecessary software testing which is labor intensive and accounts for approximately 50 percent of commercial software development costs. Often, the need to test software is caused by poor or inefficient programming practices. A more disciplined programming style would help diminish testing costs in many cases.
Finally, a concurrent concern to language evolution is a need to fully exploit the language-specific features of the chosen programming language. For instance, two features of the C++ programming language are type safety and extensibility, features formerly unavailable in the C language. Even seasoned C language programmers can sometimes overlook these features.
Other quality-related problems are caused by inexperience or lack of exposure to other programmers. As in most disciplines, knowledge of a preferred solution to a commonly encountered problem is generally passed from programmer to programmer in the time-honored oral tradition. This also means that a programmer will only grow insofar as he is able to obtain exposure to other programmers. It is unlikely a lone programmer will quickly adopt a new solution to a solved problem absent some guidance from a sage source.
One system for checking software based on rules is embodied in a computer program called lint++, as described in S. Meyers, Effective C++ 50 Specific Ways to Improve Your Programs and Designs, p. xi (Addison-Wesley 1992), the disclosure of which is incorporated herein by reference. Another system for checking software based on rules is embodied in a computer program product called CodeAdvisor, manufactured by Hewlett-Packard Company, Palo Alto, Calif., and described in E. Bailey, C++ SoftBench CodeAdvisor 5.0, SoftBench Insights, pp. 5-6 (December 1995), the disclosure of which is incorporated herein by reference.
However, these systems only focus on the particular software constructs for the C++ programming language and require rules that are reliant on detailed source code information stored in a static database. More importantly, none of the mentioned systems provide a quick, easy, and user-friendly method of generating user-defined rules that is independent of programming languages.
Therefore, what is needed is a system and method for graphically generating user-defined rules for checking computer language or source code quality that is independent of programming languages. Such a system and method would operate beyond the boundaries of the raw programming language definition and impart expert programming language knowledge by applying easily generated rules embodying extrinsic quality-related concerns, such as language evolution, portability, testing costs and language-specific feature exploitation. In general, a system and method for graphically generating user-defined rules for checking a defined relationship between a set of given information is needed.
Accordingly, the present invention enables the above problems to be overcome by providing a method and system for graphically generating user-defined rules to be used for checking quality and/or relationships of information in languages or set of given information. The created rules are usable by any compatible language. Rules are created by selecting a main node. Additional elements are added in a flow-chart-like representation to complete the graphical creation of the rule.
One embodiment of the present invention is a method and system for graphically generating user-defined rules to be used for checking the quality of a computer programming language. The created rules are usable by any compatible programming language. A Graphical User Interface (GUI) with a plurality of menus provides easy and effective means for generating user-defined rules. Generally, each rule comprises a node type associated with a matching function. Nodes and their properties are graphically generated and connected to construct rules. Each instruction in a computer programming language is represented by at least one node of a particular type stored in a parse tree for describing dependencies between such nodes. Both the parse tree and the rules are stored in the computer.
The parse tree is searched beginning from a root node indicating an entry point into the parse tree for at least one of the nodes having such a particular type matching one of the node types. The matching function associated with the matched node type is performed for analyzing the instruction represented by the node of the matched particular type by further searching the parse tree beginning from the node having the matched particular type and identifying a quality concern based on the results therefrom. An error message is generated for describing the quality concern identified by the matching function.
Because the rules are expressed in a high-level image, the underlying code can be optimized for the machine, language, or rule types. For example, sometimes rules can be combined into a single check. Additionally, the actual rule is completely portable between machines and engines, regardless of how or where the engine is running. Furthermore, some simple concepts can have many special cases in the parse tree. Representing these concepts abstractively as high-level concepts ensures that the rule will handle all (automatically handle-able) special cases. In contrast, user-written rules in terms of codes often mishandle many special cases which are hidden by the high-level rule.
Still other embodiments of the present invention will become readily apparent to those skilled in the art from the following detailed description, wherein is shown and described only embodiments of the invention by way of illustration of the best modes contemplated for carrying out the invention. As will be realized, the invention is capable of other and different embodiments and its several details are capable of modification in various obvious respects, all without departing from the spirit and scope of the present invention. Accordingly, the drawings and detailed description are to be regarded as illustrative in nature and not as restrictive.